package com.ryx.service.Impl;

import com.github.pagehelper.PageHelper;
import com.ryx.entity.SysLog;
import com.ryx.exception.GlobalException;
import com.ryx.exception.code.BaseResponseCode;
import com.ryx.mapper.SysLogMapper;
import com.ryx.service.LogService;
import com.ryx.utils.PageUtil;
import com.ryx.vo.req.SysLogPageReqVo;
import com.ryx.vo.resp.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @BelongsPackage: com.ryx.service.Impl
 * @Author: 容永轩
 * @CreateTime: 2021-01-14
 * @Description:
 */
@Service
@Transactional
public class LogServiceImpl implements LogService {

    @Autowired
    private SysLogMapper sysLogMapper;

    @Override
    public PageVo<SysLog> pageInfo(SysLogPageReqVo vo) {

        PageHelper.startPage(vo.getPageNum(),vo.getPageSize());

        return PageUtil.getPageVo(sysLogMapper.selectAll(vo));
    }

    @Override
    public void deletedLog(List<String> logIds) {
        int i = sysLogMapper.batchDeletedLog(logIds);
        if (i==0){
            throw new GlobalException(BaseResponseCode.OPERATION_ERROR);
        }
    }
}
